package com.feng.code;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * @author feng
 * @describe
 */
@Configuration
@EnableConfigurationProperties(Generator.class)
@ConditionalOnProperty(prefix = "mybatis-plus.code", name = "enable", havingValue = "true", matchIfMissing = false)
public class CodeAutoGenerator implements ApplicationRunner {
    @Autowired
    private Generator generator;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        generator.generatorCode();
        System.out.println("=====================================================================================");
        System.out.println("                            代码生成完毕，请将enable置为false");
        System.out.println("=====================================================================================");
        System.exit(0);
    }
}
